/**
 * @file ace-hacker.jsx.
 * @author liaoxuezhi@baidu.com
 *
 * brace 的插件与 fis 的模块化加载打通. 用 fis 的模块化加载去加载插件.
 */
/* eslint-disable */

const config = ace.acequire('ace/config');

const original = config.loadModule;

const map = {
  'ace/ext/beautify': __moduleId('brace/ext/beautify'),
  'ace/ext/chromevox': __moduleId('brace/ext/chromevox'),
  'ace/ext/elastic_tabstops_lite': __moduleId('brace/ext/elastic_tabstops_lite'),
  // 'ace/ext/emmet': __moduleId('brace/ext/emmet'),
  'ace/ext/error_marker': __moduleId('brace/ext/error_marker'),
  'ace/ext/keybinding_menu': __moduleId('brace/ext/keybinding_menu'),
  'ace/ext/language_tools': __moduleId('brace/ext/language_tools'),
  'ace/ext/linking': __moduleId('brace/ext/linking'),
  'ace/ext/modelist': __moduleId('brace/ext/modelist'),
  'ace/ext/old_ie': __moduleId('brace/ext/old_ie'),
  'ace/ext/searchbox': __moduleId('brace/ext/searchbox'),
  'ace/ext/settings_menu': __moduleId('brace/ext/settings_menu'),
  'ace/ext/spellcheck': __moduleId('brace/ext/spellcheck'),
  'ace/ext/split': __moduleId('brace/ext/split'),
  'ace/ext/static_highlight': __moduleId('brace/ext/static_highlight'),
  'ace/ext/statusbar': __moduleId('brace/ext/statusbar'),
  'ace/ext/textarea': __moduleId('brace/ext/textarea'),
  'ace/ext/themelist': __moduleId('brace/ext/themelist'),
  'ace/ext/whitespace': __moduleId('brace/ext/whitespace')
};

config.loadModule = (moduleName, callback) => {

  if (map[moduleName]) {
    return require([map[moduleName]], () => {
      callback(ace.acequire(moduleName));
    });
  }

  return original.apply(this, arguments);
};